<?php
/**
 * 基类,
 *
 */
abstract class lib_base_base{
 	
 	protected static $class;
 	
 	public $db;
 	
 	protected static $classObj;
 	
 	public function __construct()
 	{
 		$this->Before();
 	}
 	
 	protected function Before(){}
	
	protected  function ThewError($error='error'){
		throw new Exception($error);
	}
	
	public function __get($name){
		if(isset($this->$name)) return $this->$name;
		if(isset(self::$classObj) && is_array(self::$classObj)){
			if(array_key_exists($name,self::$classObj)){
				return self::$classObj[$name];
			}else{
				return null;
			}
		}
	}
	
	public function __set($name,$value){
		if(!isset($this->$name)){
			$this->$name=$value;
		}
	}	
	
	public function __call($name,$arguments)
	{
		static $class;
		if(isset($class[$name])) return $class[$name];
		return new $name($arguments);
	}
	
	static function regeClass($key,$class){
		if(isset(self::$class[$key])) return true;
		self::$class[$key]=$class;
	}
	
	static function All_class()
	{
		return self::$class;
	}
	
	protected function After(){}
		
	protected   function delError($e){
		die(errorHtml($e->getMessage().'.<br/>File:'.$e->getFile().',<br/>Line:'.$e->getLine()));
	}
	
	public function __destruct()
	{
		$this->After();
	}
	
}
?>